import * as bm from "/js/baseModule.js";

export class Module extends bm.baseModule {
    constructor(view) {
        super(view);
        let that = this;
    }

    // 提交原因
    _evt_updateType() {
        let that = this;
        let data = globalData;
        let demand_id = globalData.current_demand.id;
        //判断汇币余额
        //判断套餐是否过期&& (now <= endDate + dayTransMs)
        let now = new Date().getTime();
        let endDate = new Date(globalData.pack.end_date).getTime();
        let dayTransMs = 1000 * 60 * 60 * 24;//上一行代码得出的结果是截止日期当天的0点0分，所以需要在此基础上加24小时；
        //查看余额是否充足
        if (parseInt(data.pack.bid_point) >= 200) {
            //抢单
            that.find('.sendImgPending').removeClass('hide');
            let data = {
                demand_id: globalData.current_demand.id,
                feedback_type: 1
            };
            api.feedback(data, {
                succ: function () {
                    // funs.tip('反馈成功', '您的反馈信息已提交，请等待微信公众号的审核结果通知', 'succ');
                    globalData.current_demand.feedback_info.feedback_status = 2;
                    globalData.current_demand.my_follow_type = 1;
                    for (let i = 0; i < globalData.current_demand.follow_records; i++) {
                        if (globalData.current_demand.follow_records[i].nickname == globalData.user.nick) {
                            globalData.current_demand.follow_records[i].follow_type == 1;
                        }
                    }

                    that.find('.sendImgPending').addClass('hide');
                    location.hash = 'project/FeedbackDemand/FeedbackResult';
                },
                fail: function (data) {
                    that.find('.sendImgPending').addClass('hide');
                    funs.tip(data.msg, '', 'fail');
                }
            })
        } else {
            ///额度不足弹窗
            funs.openModal('modules/modals/CommonModal.JS',function (mod) {
                mod.setType(17);
            })
        }

    }
}
